#include <bits/stdc++.h>
const int N = 1e5 + 5; 
using namespace std; 
int n; 
int t[2]; 
string s[N]; 
inline int work(int x) {
	if(x < 1) return 0; 
	int sum = 0; 
	int t = 0; 
	while((1LL << t) < x) ++t; --t; 
	int dk = x - (1LL << t); 
	sum = (1LL << t) * t + dk * (t + 2); 
	return sum; 
}
inline void solve() {
	cin >> n; 
	for(int i = 1; i <= n; ++i) cin >> s[i], ++t[s[i][0] - '0']; 
	cout << work(t[0]) + work(t[1]) << "\n"; 
	return ; 
}
int main() {
	freopen("id.in", "r", stdin); 
	freopen("id.out", "w", stdout); 
	ios::sync_with_stdio(false); 
	cin.tie(0); cout.tie(0); 
	solve(); 
	return 0; 
}
